import type { App } from "vue";
import type { RouteRecordRaw } from "vue-router";
import globalRoutes from "./modules/global.ts";
import { createRouter, createWebHistory } from "vue-router";
import { createRouterGuards } from "./guards.ts";

// 创建路由实例
const router = createRouter({
    history: createWebHistory(), // createWebHashHistory URL带# createWebHistory URL不带#
    strict: true,
    routes: globalRoutes as RouteRecordRaw[],
    scrollBehavior: () => ({ left: 0, top: 0 })
});

export const setupRouter = (app: App<Element>) => {
    app.use(router);
    createRouterGuards(router);
    return router;
};

export default router;
